/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trace;
import java.io.*;
import java.util.*;


/**
 *
 * @author Julien Cassis
 */
public class Reader {

        String filename;
        BufferedReader br;

        //constructor method
        public Reader(String filename){
            this.filename = filename;
            try{
                // Get the object of DataInputStream
                DataInputStream in = new DataInputStream(new FileInputStream(this.filename));
                br = new BufferedReader(new InputStreamReader(in));
           }catch (Exception e){
                System.err.println("Error: " + e.getMessage());
           }
        }

        public String readLine(){
                String str;
                try{
                    if((str = br.readLine())!=null){
                        return str;
                    }
                }catch(Exception e){
                    System.err.println("Error: " + e.getMessage());
                }
            return null;
            }
        
        public static String[] parseString(String str){
            StringTokenizer st = new StringTokenizer(str);
            String[] array;
            if(st.countTokens()==2){
            array = new String[st.countTokens()];
            int i=0;
            while(st.hasMoreTokens()){
                array[i] = st.nextToken();
                i++;
            }
            }else{
                array = new String[2];
                array[0]=null;
                array[1]=null;
            }
            return array;
        }

        public static void parseString(String[] array, String str){
            StringTokenizer st = new StringTokenizer(str);
            if(st.countTokens()==2){
            //array = new String[st.countTokens()];
            int i=0;
            while(st.hasMoreTokens()){
                array[i] = st.nextToken();
                i++;
            }
            }else{
                //array = new String[2];
                array[0]=null;
                array[1]=null;
            }
            //return array;
        }
        
}

        
